<script setup lang="ts">
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import {login_data} from "./api/user";
import {getToKen, setToken} from "./utils/Token";
import {parseQuery} from "./utils/URLParam";

onLaunch(() => {
  console.log("App Launch");

  const { code }  = parseQuery()
  if(code) {
    login_data(code).then(res => {
      console.log('res', res);
      setToken(res.token)
    })
    return;
  }
  const token = getToKen();
  if(!token) {
    const url = encodeURIComponent('http://www.blockhunter.group')
    window.location.href =
        'https://open.weixin.qq.com/connect/oauth2/authorize?' +
        'appid=wx4807447627f6db7b' +
        '&redirect_uri=' + url +
        '&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect'
  }
});
onShow(() => {
  console.log("App Show");

});


// https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4807447627f6db7b
// &response_type=code
// &scope=snsapi_base&state=1
// &connect_redirect=1&uin=MTg1MzIyNDIyMQ%3D%3D&key=ee30f9d183064d6263b6a5763cc06f9af524b98b64859eefe2b0ec3237584a89cf351ea9074ac3a5558021936ffc4e8a&pass_ticket=wSVTpsCJgSJzSgGdLFC3PSHEEaubBHg9fbEJ6/EnmimJhSmaP5xsLd4TIsIsogQVoGGzI8We+mXv+JWQHzqKh7Y/yHfkNnULPr/mQF5fT4M=

onHide(() => {
  console.log("App Hide");
});
</script>
<style lang="scss">
page {
  --main:#24FAF6;
}
div {
  box-sizing: border-box;
}
image {
  //background: red;
}
.text-ellipsis {
  overflow: hidden; //超出的文本隐藏
  text-overflow: ellipsis; //溢出用省略号显示
  display: -webkit-box;
  -webkit-line-clamp: 1; // 超出多少行
  -webkit-box-orient: vertical;
}
.text-ellipsis-2 {
  overflow: hidden; //超出的文本隐藏
  text-overflow: ellipsis; //溢出用省略号显示
  display: -webkit-box;
  -webkit-line-clamp: 2; // 超出多少行
  -webkit-box-orient: vertical;
}

@import "./styles/index";
</style>
